package org.hot100_1;

import java.util.HashSet;
import java.util.Set;

public class leetcode8 {
    public int lengthOfLongestSubstring(String s) {
        Set<Character> set = new HashSet<>();
        int res =0;
        int left,right;

        for (left = 0; left< s.length(); left++) {
            right=left;
            while (right<s.length() && !set.contains(s.charAt(right))){
                set.add(s.charAt(right));
                right++;
            }
            set.clear();
            res=Math.max(res,right-left);
        }

        return res;
    }
}
